﻿@model StoreManager.Models.ProductSearchView
@using PagedList.Mvc
@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>Product</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.Code)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model =>  model.Code)
            @Html.ValidationMessageFor(model =>  model.Code)
        </div>
             <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model =>  model.Name)
            @Html.ValidationMessageFor(model =>  model.Name)
        </div>
     
       <p>
            <input type="submit" name="Index" value="Search" />
        </p>
    </fieldset>
}
<table>
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Code)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Name)
        </th>
        <th>
            Type
        </th>
        <th>
           Package Type
        </th>
        <th>
           Description
        </th>
        <th>
           Created
        </th>
        <th>
           Created by
        </th>
        <th></th>
    </tr>
@if(Model.SearchResults != null && Model.SearchResults.Count > 0) {
foreach (var item in Model.SearchResults)
{
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Code)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Type)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.PackType)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Description)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Created)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.CreatedBy)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.ProductID }) |
            @Html.ActionLink("Details", "Details", new { id=item.ProductID }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.ProductID })
        </td>
    </tr>
}
  <tr><td>Page
      @Html.PagedListPager(Model.SearchResults,
            page => Url.Action("Index", new RouteValueDictionary() {
               { "Page", Model.Page },
               { "Code", Model.Code },
               { "Name", Model.Name }
            }),PagedListRenderOptions.OnlyShowFivePagesAtATime)

      </td>
     </tr> 
}    
</table>
